package com.goods.controller;

import com.goods.pojo.Product;
import com.goods.service.ProductService;
import com.goods.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService service;
    //分页查询得到商品列表
    @GetMapping("/list")
    public Result getProducts(@RequestParam Integer  currentPage , @RequestParam Integer pageSize){
        return service.getProducts(currentPage,pageSize);
    }

    //新增
    @PostMapping("/add")
    public Result addProduct( @RequestBody  Product product){
        return service.addProduct(product);
    }

    //删除
    @GetMapping("/delete")
    public Result deleteProduct(@RequestParam Integer id ){
        return service.deleteProduct(id);
    }

    //修改
    @PostMapping("/update")
    public Result updateProduct(@RequestBody Product product){
        return service.updateProduct(product);
    }
}
